import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/carMold',
    component: Layout,
    redirect: '/carMold/sell',
    name: 'Mold',
    meta: { title: 'Mold' },
    children: [
      {
        path: 'sell',
        name: 'Sell',
        component: () => import('@/views/carMold/sell'),
        meta: { title: 'Sell' }
      },
      {
        path: 'lease',
        name: 'Lease',
        component: () => import('@/views/carMold/lease'),
        meta: { title: 'Lease' }
      },
      {
        path: 'leaseReturn',
        name: 'LeaseReturn',
        component: () => import('@/views/carMold/leaseReturn'),
        meta: { title: 'leaseReturn' }
      },
      {
        path: 'gift',
        name: 'Gift',
        component: () => import('@/views/carMold/gift'),
        meta: { title: 'Gift' }
      },
      {
        path: 'destroy',
        name: 'Destroy',
        component: () => import('@/views/carMold/destroy'),
        meta: { title: 'Destroy' }
      },
      {
        path: 'update',
        name: 'Update',
        component: () => import('@/views/carMold/update'),
        meta: { title: 'Update' }
      }
    ]
  },

  {
    path: '/user',
    component: Layout,
    redirect: '/user/createUser',
    name: 'User',
    meta: { title: 'User' },
    children: [
      {
        path: 'findAllUser',
        name: 'findAllUser',
        component: () => import('@/views/user/findAllUser'),
        meta: { title: 'findAllUser' }
      },
      {
        path: 'createUser',
        name: 'CreateUser',
        component: () => import('@/views/user/createUser'),
        meta: { title: 'CreateUser' }
      },
      {
        path: 'findUser',
        name: 'FindUser',
        component: () => import('@/views/user/findUser'),
        meta: { title: 'FindUser' }
      },
      {
        path: 'assetList/find',
        name: 'FindAssetList',
        component: () => import('@/views/user/findAssetList'),
        meta: { title: 'FindAssetList' }
      }
    ]
  },

  {
    path: '/asset',
    component: Layout,
    redirect: '/asset/createAsset',
    name: 'Asset',
    meta: { title: 'Asset' },
    children: [
      {
        path: 'findAllAsset',
        name: 'findAllAsset',
        component: () => import('@/views/asset/findAllAsset'),
        meta: { title: 'findAllAsset' }
      },
      {
        path: 'createAsset',
        name: 'CreateAsset',
        component: () => import('@/views/asset/createAsset'),
        meta: { title: 'CreateAsset' }
      },
      {
        path: 'findAsset',
        name: 'FindAsset',
        component: () => import('@/views/asset/findAsset'),
        meta: { title: 'FindAsset' }
      }
    ]
  },

  {
    path: '/chain',
    component: Layout,
    redirect: '/chain/findContractTxIdListById',
    name: 'Chain',
    meta: { title: 'Chain' },
    children: [
      {
        path: 'findAllChain',
        name: 'findAllChain',
        component: () => import('@/views/chain/findAllChain'),
        meta: { title: 'findAllChain' }
      },
      {
        path: 'findContractTxIdListById',
        name: 'FindIdList',
        component: () => import('@/views/chain/findContractTxIdListById'),
        meta: { title: 'FindIdList' }
      },
      {
        path: 'getMessageByTxId',
        name: 'GetTxMessage',
        component: () => import('@/views/chain/getMessageByTxId'),
        meta: { title: 'GetTxMessage' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
